package com.sitech.portal.system.service.impl;

import java.util.HashMap;
import java.util.List;

import com.sitech.portal.system.dao.ISysWorkGroupDeptDao;
import com.sitech.portal.system.domain.TblSYS_WORKGROUP_DEPT;
import com.sitech.portal.system.service.ISysWorkGroupDeptService;

public class SysWorkGroupDeptServiceImpl implements ISysWorkGroupDeptService {

	private ISysWorkGroupDeptDao sysWorkGroupDeptDao;
	
	public ISysWorkGroupDeptDao getSysWorkGroupDeptDao() {
		return sysWorkGroupDeptDao;
	}

	public void setSysWorkGroupDeptDao(ISysWorkGroupDeptDao sysWorkGroupDeptDao) {
		this.sysWorkGroupDeptDao = sysWorkGroupDeptDao;
	}

	@Override
	public void delWorkGroupDept(String deptId) {
		sysWorkGroupDeptDao.delWorkGroupDept(deptId);
	}

	@Override
	public List<HashMap> findWorkGroupDeptListByDept(String deptId) {
		// TODO Auto-generated method stub
		return sysWorkGroupDeptDao.findWorkGroupDeptListByDept(deptId);
	}

	@Override
	public List<HashMap> findWorkGroupDeptListByUser(String userId) {
		// TODO Auto-generated method stub
		return sysWorkGroupDeptDao.findWorkGroupDeptListByUser(userId);
	}

	@Override
	public void insertWorkGroupDept(List<TblSYS_WORKGROUP_DEPT> list) {
		for(TblSYS_WORKGROUP_DEPT obj : list){
			sysWorkGroupDeptDao.insertWorkGroupDept(obj);
		}
	}

	@Override
	public void insertWorkGroupDept(TblSYS_WORKGROUP_DEPT obj) {
		// TODO Auto-generated method stub
		sysWorkGroupDeptDao.insertWorkGroupDept(obj);
	}

	@Override
	public void updateWorkGroupDept(String deptId, String userId,
			String[] workGroupIds) {
		sysWorkGroupDeptDao.delWorkGroupDept(deptId);
		for(int i=0;i<workGroupIds.length;i++){
			String roleId = workGroupIds[i];
			TblSYS_WORKGROUP_DEPT obj = new TblSYS_WORKGROUP_DEPT();
			obj.setDEPT_ID(deptId);
			obj.setUSER_ID(userId);
			obj.setWORKGROUP_ID(roleId);
			sysWorkGroupDeptDao.insertWorkGroupDept(obj);
		}
	}

}
